package org.cresource.order.controller;

import org.cresource.basic.util.AjaxResult;
import org.cresource.basic.util.LoginContext;
import org.cresource.order.service.IAdoptOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/adopt")
public class AdoptOrderController {
    @Autowired
    IAdoptOrderService adoptOrderService;


//    立即购买
//    立即购买
//    立即购买
@PostMapping("/submit")
public AjaxResult submit(@RequestBody Map<String,Object> params, HttpServletRequest request){
    try{
        String payData = adoptOrderService.submit(params, LoginContext.getLoginInfo(request));
        return AjaxResult.me().setResultObj(payData);
    }catch (Exception e){
        e.printStackTrace();
        return AjaxResult.me().setSuccess(false).setMessage("下单失败！"+e.getMessage());
    }

}
}
